<?php


namespace org;

use think\Controller;
use think\Db;
use think\Request;
use Qcloud\Cos\Client;
use Qcloud\Cos\Exception\ServiceResponseException;


class TencentCos extends Controller{
    const SYNC_TIME = 5;
    private $config = [];
    private $cosClient;
    public function __initialize()
    {
        $storage_config=Db::name('storage')->field('tencent')
            ->where('acid',1)
            ->find();
        $this->config = json_decode($storage_config['tencent'], true);

        $this->cosClient = new Client(array('region' => $this->config['region'],
            'credentials' => array(
                'secretId' => $this->config['secretId'],
                'secretKey' => $this->config['secretKey']
            )));
        try {
            $this->cosClient->createBucket(['Bucket' => $this->config['bucket']]);
        } catch(\Exception $e) {
        }
    }





}